<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
		<link rel="stylesheet" href="../../assets/css/layui.css">
		<link rel="stylesheet" href="../../assets/css/view.css"/>
	</head>

	<body class="layui-view-body">
		<div class="layui-content">
			<div class="layui-row">
				<div class="layui-card">
					<div class="layui-card-header">添加快递员</div>
					<form id="form" class="layui-form layui-card-body">

						<div class="layui-form-item">
							<label class="layui-form-label">姓名</label>
							<div class="layui-input-block">
								<input type="text" id="name" name="name" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">手机号码</label>
							<div class="layui-input-block">
									<input onblur="isPhoneNum()" type="text" id="phone" name="phone" required  lay-verify="required" placeholder="请输入手机号码" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">身份证号码</label>
							<div class="layui-input-block">
								<input onblur="checkCard()" id="idCard" type="text" name="idCard" required  lay-verify="required" placeholder="请输入身份证号码" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">密码</label>
							<div class="layui-input-block">
								<input id="password" type="text" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">简介</label>
							<div class="layui-input-block">
								<input id="info" type="text" name="info" required  lay-verify="required" placeholder="请输入简介" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button type="submit" class="layui-btn layui-btn-blue" lay-submit lay-filter="formDemo">立即提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>

		<!-- / 表示web文件夹，也就是根目录 -->
		<script src="/qrcode/jquery2.1.4.js"></script>
		<script src="/layer/layer.js"></script>
		<script src="../../assets/layui.all.js"></script>


		<script>
			var form = layui.form
					,layer = layui.layer;
		</script>

		<script>
			$(function () {

				$("#form").submit(function () {
					// 1、获取页面参数并通过ajax与服务器进行交互
					var name = $("input:eq(0)").val();
					var phone = $("input:eq(1)").val();
					var idCard = $("input:eq(2)").val();
					var password = $("input:eq(3)").val();
					var info = $("input:eq(4)").val();

					/*var blur = $("#phone").blur(isPhoneNum(phone));
					var blur1 = $("#idCard").blur(checkCard(idCard));*/


					// 1、获取页面参数并通过ajax与服务器进行交互
					name = $("input:eq(0)").val();
					phone = $("input:eq(1)").val();
					idCard = $("input:eq(2)").val();
					password = $("input:eq(3)").val();
					info = $("input:eq(4)").val();
					// 2、经典转圈
					var windowId = layer.load();
					$.getJSON("/courier/insert.do", {
						// 要传递给后台（服务器）的数据
						// 后端只需要通过request请求对象进行获取参数即可
						name:name,
						phone:phone,
						idCard:idCard,
						password:password,
						info:info
					},function (data) {
						// 3、关闭load窗口
						layer.close(windowId);
						layer.msg(data.result,function () {
							if (data.status==0){
								// 录入成功
								$("input").val("");
							}else {
								// 录入失败
							}
						});
					});


					return false;
				});


			});
		</script>

		<script>
			function checkCard() {
					/*
                    * 18位数身份证正则表达式:
                    * 编码规则顺序从左至右依次为6位数字地址码，8位数字出生年份日期码，3位数字顺序码，1
                    位数字校验码（可为x）。
                    [1-9]\d{5} 前六位地区，非0打头
                    (18|19|([23]\d))\d{2} 出身年份，覆盖范围为 1800-3999 年
                    ((0[1-9])|(10|11|12)) 月份，01-12月
                    (([0-2][1-9])|10|20|30|31) 日期，01-31天
                    \d{3}[0-9Xx]： 顺序码三位 + 一位校验码
                    */
					/*/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;*/
					/*var arg2 = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$ /;*/

					var str = document.getElementById("idCard").value;

					var arg2 = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;

					if (!arg2.test(str)){
						layer.alert("请正确输入身份证号码！");
					}
					return arg2.test(str);
			}

			/*校验手机号*/
			function isPhoneNum() {
				// 如果因为现有的号码不能满足市场需求，电信服务商会增大号码范围。
				// 所以一般情况下只要验证手机号码为11位，且以1开头。

				var str = document.getElementById("phone").value;

				var reg = /^^1[0-9]{10}$$/;
				if (!reg.test(str)){
					layer.alert("请正确输入手机号！")
				}
				return reg.test(str);
			}

		</script>
		<script>

		</script>
	</body>
</html>

<!--<script src="../../assets/layui.all.js"></script>
<script src="/qrcode/jquery2.1.4.js"></script>
<script src="/layer/layer.js"></script>
<script>
	var form = layui.form
			,layer = layui.layer;
</script>
<script>
	$(function(){
		$("#form").submit(function(){
			var windowId = layer.load();
			var number = $("input:eq(0)").val();
			var company = $("input:eq(1)").val();
			var username = $("input:eq(2)").val();
			var userPhone = $("input:eq(3)").val();
			$.post("/express/insert.do",{
				number:number,
				company:company,
				username:username,
				userPhone:userPhone
			},function(data){
				layer.close(windowId);
				layer.msg(data.result);
				if(data.status == 0){
					//录入成功
					$("input").val("");
					$("input:eq(1)").val("顺丰速运");
				}else{
					//录入失败
				}
			});

			return false;
		});


	});
</script>-->
